﻿// Vacuum Pressure and Battery Ammeter - 真空空压电池电量表

#include "VacuumBattery.h"

void drawVBT(double circle_x, double circle_y, double circle_r, double angle, double angle2)
{
//    double circle_x, circle_y, circle_r;//圆心和半径
//    circle_x = 600, circle_y = 400, circle_r = 200;
    //initgraph(1200, 800, INIT_RENDERMANUAL);//手动渲染，避免闪烁
    ege_enable_aa(true);//抗锯齿
//    setbkcolor(WHITE);//背景色白色
    settextjustify(LEFT_TEXT, TOP_TEXT);
    

    {
        if (angle2 < 3) {
            angle2 = 3;
        }

        if (angle2 > 7) {
            angle2 = 7;
        }
    }//限制范围

    {

        angle = angle * M_PI / 240;//电流
        angle2 = -(angle2 - 5) * 4.5 * M_PI / 36;//压力
        
    }//电流，压力转换公式
    
   

    g2(circle_x, circle_y, circle_r);//图形
    leftzhizhen(circle_x, circle_y, circle_r, angle2);//左指针压力
    rightzhizhen(circle_x, circle_y, circle_r, angle);//右指针电流
    cover(circle_x, circle_y, circle_r);


    key_msg msg;

//    for (; is_run(); delay_fps(60)) {
//        msg = getkey();
//        if (msg.key == key_left && msg.msg == key_msg_down) {
//            if (angle > 65 * M_PI / 180 || angle < -65 * M_PI / 180) {
//                if (angle > 65 * M_PI / 180) {
//                    angle -= 0.015;
//                }
//                else {
//                    angle += 0.015;
//                }
//                continue;
//            }
//            angle -= 0.015;
//            cleardevice();
//            g2(circle_x, circle_y, circle_r);//图形
//            leftzhizhen(circle_x, circle_y, circle_r, angle);//左指针
//            rightzhizhen(circle_x, circle_y, circle_r, angle);//右指针
//            fugai(circle_x, circle_y, circle_r);
//        }
//        else if (msg.key == key_right && msg.msg == key_msg_down) {
//            if (angle > 65 * M_PI / 180 || angle < -65 * M_PI / 180) {
//                if (angle > 65 * M_PI / 180) {
//                    angle -= 0.015;
//                }
//                else {
//                    angle += 0.015;
//                }
//                continue;
//            }
//            angle += 0.015;
//            cleardevice();
//            g2(circle_x, circle_y, circle_r);//图形
//            leftzhizhen(circle_x, circle_y, circle_r, angle); // 再绘制指针
//            rightzhizhen(circle_x, circle_y, circle_r, angle);
//            fugai(circle_x, circle_y, circle_r);      // 先绘制覆盖层（仅根部区域）
//        }
//    }//指针旋转
}

void g2(double circle_x, double circle_y, double circle_r) {
    //setfillcolor(BLACK);//填充色为黑色,不透明
    //ege_fillrect(circle_x - circle_r * 8 / 6, circle_y - circle_r * 8 / 6, circle_r * 8 / 3, circle_r * 8 / 3);//边框
    //setfillcolor(EGERGB(100, 100, 100));//填充为灰色
    //ege_fillrect(circle_x - circle_r * 8 / 6 + circle_r / 60, circle_y - circle_r * 8 / 6 + circle_r / 60, circle_r * 8 / 3 - circle_r / 30, circle_r * 8 / 3 - circle_r / 30);//边框

    //{
    //    ege_point p = { circle_x - circle_r * 21 * 1 / 24 - circle_r / 17 ,circle_y - circle_r * 21 * 0.96 / 24 - circle_r / 17 };
    //    ege_setpattern_ellipsegradient(p, EGERGB(230, 230, 230), circle_x - circle_r * 21 / 24 - circle_r / 10, circle_y - circle_r * 21 / 24 - circle_r * 0.7 / 10, circle_r / 6, circle_r / 6, EGEACOLOR(0xFF, 0x000000));
    //    ege_fillrect(circle_x - circle_r * 21 / 24 - circle_r / 10, circle_y - circle_r * 21 / 24 - circle_r / 10, circle_r / 4, circle_r / 4);//左上角

    //    ege_point p2 = { circle_x + circle_r * 21 / 24 - circle_r / 17 ,circle_y - circle_r * 21 / 24 - circle_r / 17 };
    //    ege_setpattern_ellipsegradient(p2, EGERGB(230, 230, 230), circle_x + circle_r * 21 / 24 - circle_r / 10, circle_y - circle_r * 21 / 24 - circle_r / 10, circle_r / 6, circle_r / 6, EGEACOLOR(0xFF, 0x000000));
    //    ege_fillrect(circle_x + circle_r * 21 / 24 - circle_r / 10, circle_y - circle_r * 21 / 24 - circle_r / 10, circle_r / 4, circle_r / 4);//右上角

    //    ege_point p3 = { circle_x - circle_r * 21 / 24 - circle_r / 17 ,circle_y + circle_r * 21 / 24 - circle_r / 17 };
    //    ege_setpattern_ellipsegradient(p3, EGERGB(230, 230, 230), circle_x - circle_r * 21 / 24 - circle_r / 10, circle_y + circle_r * 21 / 24 - circle_r / 10, circle_r / 6, circle_r / 6, EGEACOLOR(0xFF, 0x000000));
    //    ege_fillrect(circle_x - circle_r * 21 / 24 - circle_r / 10, circle_y + circle_r * 21 / 24 - circle_r / 10, circle_r / 4, circle_r / 4);//左下角

    //    ege_point p4 = { circle_x + circle_r * 43 / 48 - circle_r / 17 ,circle_y + circle_r * 21 * 1.02 / 24 - circle_r / 17 };
    //    ege_setpattern_ellipsegradient(p4, EGERGB(230, 230, 230), circle_x + circle_r * 43 / 48 - circle_r / 10, circle_y + circle_r * 21 * 1.01 / 24 - circle_r / 10, circle_r / 6, circle_r / 6, EGEACOLOR(0xFF, 0x000000));
    //    ege_fillrect(circle_x + circle_r * 43 / 48 - circle_r / 10, circle_y + circle_r * 21 / 24 - circle_r / 10, circle_r / 4, circle_r / 4);//右下角
    //}//螺丝
    screwcVBT(circle_x, circle_y, circle_r);

    setfillcolor(EGERGB(0, 0, 0));//黑色,不透
    {
        //setcolor(BLACK);//描边颜色
        //setlinewidth(15);//线条粗细
        //ege_circle(circle_x, circle_y, circle_r + circle_r / 10);//描边

        ege_point p5 = { circle_x - circle_r - circle_r / 10 + circle_r / 30 * 11 - circle_r / 4 * 1.4 ,circle_y - circle_r - circle_r / 10 + circle_r / 30 * 11 + circle_r / 2 * 1.5  };
        ege_setpattern_ellipsegradient(p5, EGERGB(190, 190, 190), circle_x - circle_r - circle_r / 10, circle_y - circle_r - circle_r / 10, 2 * (circle_r + circle_r / 10), 2 * (circle_r + circle_r / 10), EGERGB(30, 30, 30));
        ege_fillrect(circle_x - circle_r - circle_r / 10, circle_y - circle_r - circle_r / 10, 2 * (circle_r + circle_r / 10), 2 * (circle_r + circle_r / 10));

    }//最外圈

    {
        ege_point p6 = { circle_x + circle_r + circle_r / 300 * 2 - circle_r / 30 * 10 ,circle_y - circle_r - circle_r / 300 * 2 + circle_r / 30 * 19 };
        ege_setpattern_ellipsegradient(p6, EGERGB(195,195 ,195), circle_x - circle_r - circle_r / 300 * 13, circle_y - circle_r - circle_r / 300 * 13, 2 * (circle_r + circle_r / 300 * 13), 2 * (circle_r + circle_r / 300 * 13), EGEACOLOR(0xFF, 0x373533));
        ege_fillrect(circle_x - circle_r - circle_r / 300 * 13, circle_y - circle_r - circle_r / 300 * 13, 2 * (circle_r + circle_r / 300 * 13), 2 * (circle_r + circle_r / 300 * 13));
        setlinewidth(circle_r / 100 * 4);//线条粗细
        setcolor(EGEACOLOR(0xFF, 0x1B1916));
        ege_circle(circle_x, circle_y, circle_r + circle_r / 25);
    }//第二圈

    {
        setfillcolor(EGEACOLOR(0xFF, 0x211D19));
        ege_fillcircle(circle_x,circle_y,circle_r - circle_r / 10);
        setcolor(BLACK);//线条颜色
        setlinewidth(circle_r / 100);//线条粗细
        ege_circle(circle_x, circle_y, circle_r - circle_r / 10);//描边
    }//第三圈

    {
        setfillcolor(EGEACOLOR(0XFF, 0x33322F));
        setlinewidth( 3);//线条粗细
        setcolor(EGEACOLOR(0XFF, 0x33322F));//线条颜色
        ege_line(circle_x - (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x - (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//左边线
        ege_line(circle_x + (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x + (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//右边线
        ege_circle(circle_x,circle_y,circle_r - circle_r / 10);//闭合
        floodfill(circle_x, circle_y , EGEACOLOR(0XFF, 0x33322F));//填充矩形区域
        setcolor(BLACK);//线条颜色
        setlinewidth(2);//线条粗细
        ege_circle(circle_x, circle_y, circle_r - circle_r / 10);//描边
        //2E2A26
        drawScale1(circle_x, circle_y, circle_r);//左边刻度
        drawScale2(circle_x, circle_y, circle_r);//右边刻度
    }//矩形区域

    {
        setcolor(EGERGB(210, 210, 210));
        setbkmode(TRANSPARENT);//去除文字背景色
        setfont(circle_r / 200 * 40, circle_r / 200 * 20, "Arial Bold");
        outtextxy((circle_x - circle_r * 0.7), circle_y - circle_r / 3, "V");
        outtextxy((circle_x - circle_r * 0.7), circle_y - circle_r / 12,"A");
        outtextxy((circle_x - circle_r * 0.7), circle_y + circle_r / 6, "C");
        outtextxy((circle_x + circle_r * 0.55), circle_y - circle_r / 3, "A");
        outtextxy((circle_x + circle_r * 0.55), circle_y - circle_r / 12, "M");
        outtextxy((circle_x + circle_r * 0.55), circle_y + circle_r / 6, "P");
        setfont(circle_r / 200 * 25, circle_r / 200 * 8, "Arial Bold");
        outtextxy((circle_x - circle_r * 0.46), circle_y - circle_r / 9, "IN.");
        outtextxy((circle_x - circle_r * 0.46), circle_y , "Hg.");
        setfont(circle_r / 200 * 36, circle_r / 200 * 18, "Arial Bold");
        outtextxy((circle_x - circle_r * 0.75) + circle_r * 0.72 * cos((22.5 - 67.5) * M_PI / 180), circle_y + circle_r * 0.72 * sin((22.5 - 67.5) * M_PI / 180) - circle_r / 6,"7");
        outtextxy((circle_x - circle_r * 0.75) + circle_r * 0.72 * cos((22.5 * 2 - 67.5) * M_PI / 180) - circle_r / 4.5, circle_y + circle_r * 0.72 * sin((22.5 * 2 - 67.5) * M_PI / 180) - circle_r / 80, "6");
        outtextxy((circle_x - circle_r * 0.75) + circle_r * 0.72 * cos((22.5 * 3 - 67.5) * M_PI / 180) - circle_r / 4.5, circle_y + circle_r * 0.72 * sin((22.5 * 3 - 67.5) * M_PI / 180) - circle_r /13, "5");
        outtextxy((circle_x - circle_r * 0.75) + circle_r * 0.72 * cos((22.5 * 4 - 67.5) * M_PI / 180) - circle_r / 4.5, circle_y + circle_r * 0.72 * sin((22.5 * 4 - 67.5) * M_PI / 180) - circle_r / 5, "4");
        outtextxy((circle_x - circle_r * 0.75) + circle_r * 0.72 * cos((22.5 * 5 - 67.5) * M_PI / 180), circle_y + circle_r * 0.72 * sin((22.5 * 5 - 67.5) * M_PI / 180), "3");


        outtextxy((circle_x + circle_r * 0.75) + circle_r * 0.72 * cos((1 * -22.5 - 112.5) * M_PI / 180) - circle_r * 0.2, circle_y + circle_r * 0.72 * sin((1 * -22.5 - 112.5) * M_PI / 180) - circle_r / 6, "+60");
        outtextxy((circle_x + circle_r * 0.75) + circle_r * 0.72 * cos((2 * -22.5 - 112.5) * M_PI / 180) + circle_r / 7, circle_y + circle_r * 0.72 * sin((2 * -22.5 - 112.5) * M_PI / 180) - circle_r / 80, "30");
        outtextxy((circle_x + circle_r * 0.75) + circle_r * 0.72 * cos((3 * -22.5 - 112.5) * M_PI / 180) + circle_r / 7, circle_y + circle_r * 0.72 * sin((3 * -22.5 - 112.5) * M_PI / 180) - circle_r / 13, "0");
        outtextxy((circle_x + circle_r * 0.75) + circle_r * 0.72 * cos((4 * -22.5 - 112.5) * M_PI / 180) + circle_r / 7, circle_y + circle_r * 0.72 * sin((4 * -22.5 - 112.5) * M_PI / 180) - circle_r / 5, "30");
        outtextxy((circle_x + circle_r * 0.75) + circle_r * 0.72 * cos((5 * -22.5 - 112.5) * M_PI / 180) - circle_r / 6, circle_y + circle_r * 0.72 * sin((5 * -22.5 - 112.5) * M_PI / 180), "-60");
    }//字
}
// 绘制左边刻度
void drawScale1(double circle_x, double circle_y,double circle_r) {
    setcolor(EGEACOLOR(0XFF, 0x6A8744));//绿色
    setlinewidth(circle_r / 200 * 15);//绿色弧线粗度
    ege_arc((circle_x - circle_r * 0.75) - circle_r * 0.67, circle_y - circle_r * 0.67, 2 * circle_r * 0.67, 2 * circle_r * 0.67, -11, 22);//绿色弧线
    setcolor(EGERGB(210,210,210));//线条颜色
    for (int i = 1; i <= 5; i++) {
        double rad = (i * 22.5 - 67.5) * M_PI / 180;
        int x1 = (circle_x - circle_r * 0.75) + circle_r * 0.72 * cos(rad);
        int y1 = circle_y + circle_r * 0.72 * sin(rad);
        int x2 = (circle_x - circle_r * 0.75) + circle_r / 1.65 * cos(rad);
        int y2 = circle_y + circle_r / 1.65 * sin(rad);
        setlinewidth(circle_r / 200 * 7);//大线条粗细
        ege_line(x1,y1,x2,y2);
    }
    
}

// 绘制右边刻度
void drawScale2(double circle_x, double circle_y, double circle_r) {
    setcolor(EGERGB(210, 210, 210));//线条颜色
    for (int i = 1; i <= 5; i++) {
        double rad = (i * -22.5 - 112.5) * M_PI / 180;
        int x1 = (circle_x + circle_r * 0.75) + circle_r * 0.72 * cos(rad);
        int y1 = circle_y + circle_r * 0.72 * sin(rad);
        int x2 = (circle_x + circle_r * 0.75) + circle_r / 1.65 * cos(rad);
        int y2 = circle_y + circle_r / 1.65 * sin(rad);
        setlinewidth(circle_r / 200 * 7);//大线条粗细
        ege_line(x1, y1, x2, y2);
    }
    for (int i = 1; i <= 3; i++) {
        double rad = (i * -22.5 - 146.25) * M_PI / 180;
        int x1 = (circle_x + circle_r * 0.75) + circle_r * 0.72 * cos(rad);
        int y1 = circle_y + circle_r * 0.72 * sin(rad);
        int x2 = (circle_x + circle_r * 0.75) + circle_r / 1.65 * cos(rad);
        int y2 = circle_y + circle_r / 1.65 * sin(rad);
        setlinewidth(circle_r / 200 * 4);//大线条粗细
        ege_line(x1, y1, x2, y2);
    }
}
//左边指针
void leftzhizhen(double circle_x,double circle_y,double circle_r,double angle) {
    setfillcolor(EGERGB(230, 230, 230));
    ege_point p[] = {
            { 0, 0},
            {circle_r * 0.02, -circle_r * 0.05},
            {circle_r * 0.72 , -circle_r * 0.02},
            {circle_r * 0.72 , circle_r * 0.02},
            {circle_r * 0.02, circle_r * 0.05}
    };
    ege_point px[5] = { 0 };
    for (int i = 0; i < 5; i++) {
        double x = p[i].x;
        double y = p[i].y;
        px[i].x = circle_x - circle_r * 0.75 + x * cos(angle) - y * sin(angle);
        px[i].y = circle_y + x * sin(angle) + y * cos(angle);
    }
    ege_fillpoly(5, px);
}
//右边指针
void rightzhizhen(double circle_x, double circle_y,double circle_r,double angle){
    setfillcolor(EGERGB(230, 230, 230));
    ege_point p[] = {
            { 0, 0},
            {-circle_r * 0.02, -circle_r * 0.05},
            {-circle_r * 0.72 , -circle_r * 0.02},
            {-circle_r * 0.72 , circle_r * 0.02},
            {-circle_r * 0.02, circle_r * 0.05}
    };
    ege_point px[5] = { 0 };
    for (int i = 0; i < 5; i++) {
        double x = p[i].x;
        double y = p[i].y;
        px[i].x = circle_x + circle_r * 0.75 + x * cos(angle) - y * sin(angle);
        px[i].y = circle_y + x * sin(angle) + y * cos(angle);
    }
    ege_fillpoly(5, px);
}

void cover(double circle_x,double circle_y,double circle_r) {

    setfillcolor(EGEACOLOR(0XFF, 0x211D19));
    setlinewidth(3);//线条粗细
    setcolor(EGEACOLOR(0XFF, 0x211D19));//线条颜色
    ege_line(circle_x - (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x - (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//左边线
    ege_line(circle_x + (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x + (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//右边线
    ege_circle(circle_x, circle_y, circle_r - circle_r / 10);//闭合
    floodfill(circle_x - circle_r * 0.73, circle_y, EGEACOLOR(0XFF, 0x211D19));//填充矩形区域
    floodfill(circle_x + circle_r * 0.73, circle_y, EGEACOLOR(0XFF, 0x211D19));//填充矩形区域

    {
        setlinewidth(3);//线条粗细
        setcolor(EGEACOLOR(0XFF, 0x33322F));//线条颜色
        ege_line(circle_x - (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x - (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//左边线
        ege_line(circle_x + (circle_r - circle_r / 10) * 0.53, circle_y - (circle_r - circle_r / 10) * 0.85, circle_x + (circle_r - circle_r / 10) * 0.53, circle_y + (circle_r - circle_r / 10) * 0.85);//右边线
        setcolor(BLACK);//线条颜色
        setlinewidth(2);//线条粗细
        ege_circle(circle_x, circle_y, circle_r - circle_r / 10);//描边
    }//复原

    setcolor(EGERGB(210, 210, 210));
    setbkmode(TRANSPARENT);//去除文字背景色
    setfont(circle_r / 200 * 40, circle_r / 200 * 20, "Arial Bold");
    outtextxy((circle_x - circle_r * 0.7), circle_y - circle_r / 3, "V");
    outtextxy((circle_x - circle_r * 0.7), circle_y - circle_r / 12, "A");
    outtextxy((circle_x - circle_r * 0.7), circle_y + circle_r / 6, "C");
    outtextxy((circle_x + circle_r * 0.55), circle_y - circle_r / 3, "A");
    outtextxy((circle_x + circle_r * 0.55), circle_y - circle_r / 12, "M");
    outtextxy((circle_x + circle_r * 0.55), circle_y + circle_r / 6, "P");
}

void screwcVBT(double centerX, double centerY, double dialRadius)
{
    // 使用float保证计算精度（根据需求可改为double）
    const float DIAL_RADIUS_F = (float)dialRadius;
    const float CENTER_X_F = (float)centerX;
    const float CENTER_Y_F = (float)centerY;

    // 参数化定义（精确到小数点后6位）
    const float SCREW_OFFSET = DIAL_RADIUS_F * 0.055555556f; // 1/18
    const float ELLIPSE_OFFSET_X = -DIAL_RADIUS_F * 0.111111111f; // -1/9
    const float ELLIPSE_OFFSET_Y = -DIAL_RADIUS_F * 0.166666667f; // -1/6
    const float ELLIPSE_SIZE = DIAL_RADIUS_F * 0.277777778f;  // 5/18
    const float RECT_OFFSET_X = DIAL_RADIUS_F * 0.222222222f;  // 2/9
    const float RECT_OFFSET_Y = DIAL_RADIUS_F * 0.333333333f;  // 1/3
    const float RECT_WIDTH = DIAL_RADIUS_F * 0.555555556f;   // 5/9
    const float RECT_HEIGHT = DIAL_RADIUS_F * 0.611111111f;  // 11/18
    const float CROSS_OFFSET1 = DIAL_RADIUS_F * 0.055555556f;  // 1/18
    const float CROSS_OFFSET2 = DIAL_RADIUS_F * 0.027777778f;  // 1/36
    const float LINE_WIDTH = DIAL_RADIUS_F * 0.016666667f;  // 1/60

    ege_enable_aa(TRUE);

    // 绘制函数（使用浮点坐标）
    auto draw_screw = [&](float cx, float cy) {
        // 精确到小数点后6位的渐变参数
        ege_setpattern_ellipsegradient(
            ege_point{ roundf(cx), roundf(cy) }, // 最终转整数
            EGEACOLOR(0xFF, BLACK),
            roundf(cx + ELLIPSE_OFFSET_X),
            roundf(cy + ELLIPSE_OFFSET_Y),
            roundf(ELLIPSE_SIZE),
            roundf(ELLIPSE_SIZE),
            EGEACOLOR(0, WHITE)
        );
        ege_fillrect(
            roundf(cx - RECT_OFFSET_X),
            roundf(cy - RECT_OFFSET_Y),
            roundf(RECT_WIDTH),
            roundf(RECT_HEIGHT)
        );

        // 灰色渐变层（精确尺寸调整）
        const float adjusted_size = ELLIPSE_SIZE - DIAL_RADIUS_F * 0.055555556f; // 替代原-10
        ege_setpattern_ellipsegradient(
            ege_point{
              roundf(cx - SCREW_OFFSET * 0.5f),
                roundf(cy - SCREW_OFFSET * 0.5f)
            },
            EGEACOLOR(0xFF, EGERGB(170, 170, 170)),
            roundf(cx + ELLIPSE_OFFSET_X),
            roundf(cy + ELLIPSE_OFFSET_Y),
            roundf(adjusted_size),
            roundf(adjusted_size),
            EGEACOLOR(0xFF, EGERGB(20, 20, 20))
        );
        ege_fillrect(
            roundf(cx - RECT_OFFSET_X),
            roundf(cy - RECT_OFFSET_Y),
            roundf(RECT_WIDTH),
            roundf(RECT_HEIGHT)
        );

        // 十字线（亚像素级精度）
        setcolor(EGERGB(30, 30, 30));
        setlinewidth(roundf(LINE_WIDTH));

        const float cross_y = cy - CROSS_OFFSET2 * 2.0f;
        ege_line(
            roundf(cx - CROSS_OFFSET1), roundf(cross_y),
            roundf(cx + CROSS_OFFSET1), roundf(cross_y)
        );

        const float cross_x = cx;
        const float cross_y_start = cy + CROSS_OFFSET2 / 4;
        const float cross_y_end = cy - CROSS_OFFSET2 * 4.0f;
        ege_line(
            roundf(cross_x), roundf(cross_y_start),
            roundf(cross_x), roundf(cross_y_end)
        );
        };

    // 计算四个螺丝中心坐标（浮点运算）
    const float screw_radius = DIAL_RADIUS_F - SCREW_OFFSET;

    // 左上
    draw_screw(
        CENTER_X_F - screw_radius,
        CENTER_Y_F - DIAL_RADIUS_F
    );

    // 右上
    draw_screw(
        CENTER_X_F + screw_radius,
        CENTER_Y_F - DIAL_RADIUS_F
    );

    // 右下
    draw_screw(
        CENTER_X_F + screw_radius,
        CENTER_Y_F + DIAL_RADIUS_F
    );

    // 左下（新增）
    draw_screw(
        CENTER_X_F - screw_radius,
        CENTER_Y_F + DIAL_RADIUS_F
    );
}